/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.tnmk.worktime.gui.tbl;

import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import org.joda.time.DateTime;
import org.tnmk.worktime.utils.TimeUtils;

/**
 *
 * @author Administrator
 */
public class DateCellRenderer extends DecorateDefaultTableCellRenderer {
  public DateCellRenderer(){super();}
  public DateCellRenderer(DefaultTableCellRenderer previousRenderer) {
    super(previousRenderer);
  }

  @Override
  public Component getTableCellRendererComponent(JLabel comp, JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    if (value instanceof DateTime) {
      DateTime dt = (DateTime) value;
      String dts = TimeUtils.toString(dt, TimeUtils.DEFAULT_DATE_PATTERN);
      comp.setText(dts);
    }
    return comp;
  }
}
